{extend  name="./app" /}

{block name="title"}句子详情{/block}

{block name="body"}
<div class="container">
    <div class="row">
        <div class="col-sm-12">
            <ol class="breadcrumb">
                <li><a href="{:url1('/')}">首页</a></li>
                <li><a href="#">句子详情</a></li>
            </ol>
        </div>
        <div class="col-sm-12">
            <div class="panel panel-default">
                <div class="panel-body">
                    <p>{$sentence->sentence}</p>
                    <p>
                        {if condition="$sentence->tags"}
                        {volist name="$sentence->tags" id="tag"}
                        <span class="label label-default">{$tag->name}</span>
                        {/volist}
                        {/if}
                    </p>
                    <p class="color-gray text-right">创建时间：{$sentence->create_time}</p>
                </div>
                {if condition="$sentence->user"}
                <div class="panel-footer">
                    <p class="text-right">
                        ——&nbsp;<b>{$sentence->user->username}</b>
                        {if condition="$user && $sentence->user_id == $user->id"}
                        <a href="{:url1('index/sentence/edit', ['id' => $sentence->id])}">编辑</a>
                        <a onclick="return confirm('确定删除？')" href="{:url1('index/sentence/destroy', ['id' => $sentence->id])}">删除</a>
                        {/if}
                    </p>
                </div>
                {/if}
            </div>
        </div>

        <div style="margin-top: 20px;" class="col-sm-12">
            <div class="col-sm-12">
                <form action="{:url1('index/sentence/commentHandler', ['sid' => $sentence->id])}" method="post" class="form-horizontal">
                    <div class="form-group">
                        <textarea name="content" class="form-control" rows="3" placeholder="评论内容"></textarea>
                    </div>
                    <div class="form-group text-right">
                        <button type="submit" class="btn btn-primary">提交评论</button>
                    </div>
                </form>
            </div>
        </div>

        <div class="col-sm-12">
            <p><a href="#" class="color-gray">共{$sentence->comments->count()}条</a></p>
        </div>
        <div class="col-sm-12">
            {if condition="$sentence->comments"}
            {volist name="$sentence->comments" id="comment"}
            <div class="panel panel-default">
                <div class="panel-heading">
                    {$comment->user->username}
                </div>
                <div class="panel-body">{$comment->content}</div>
                <div class="panel-footer">
                    <p class="text-right">{$comment->create_time}</p>
                </div>
            </div>
            {/volist}
            {else}
            <p class="text-center color-gray">0评论</p>
            {/if}
        </div>

    </div>
</div>
{/block}